/*
 * Copyright (c) 2012-2014, EpicSaaS Yuan Xin technology Co., Ltd.
 * 
 * All rights reserved.
 */
package com.epicsaas.app.ksdapp.controller.phone;

import com.epicpaas.sdk.core.api.logging.Logger;
import com.epicpaas.sdk.core.api.logging.LoggerFactory;
import com.epicpaas.sdk.core.api.ServiceResult;
import com.epicsaas.framework.util.DateTimeUtils;
import com.epicsaas.app.ksdapp.android.bean.CouponCode;
import com.epicsaas.app.ksdapp.android.bean.Logistics;
import com.epicsaas.app.ksdapp.android.bean.MyConsigneeAddress;
import com.epicsaas.app.ksdapp.android.bean.MyMessage;
import com.epicsaas.app.ksdapp.android.bean.OrderDTO;
import com.epicsaas.app.ksdapp.android.bean.Product;
import com.epicsaas.app.ksdapp.android.bean.Reviews;
import com.epicsaas.app.ksdapp.android.bean.UserBaseInfo;
import com.epicsaas.app.ksdapp.android.bean.MyMessage.Type;
import com.epicsaas.app.ksdapp.android.bean.OrderList;
import com.epicsaas.app.ksdapp.android.bean.PageEntity;
import com.epicsaas.app.ksdapp.android.bean.UserInfo;
import com.epicsaas.app.ksdapp.appobject.UserAO;
import com.epicsaas.app.ksdapp.common.MVCViewName;
import com.epicsaas.app.ksdapp.entity.gen.UserCriteria;
import com.epicsaas.app.ksdapp.service.IUserService;
import com.epicsaas.app.ksdapp.util.HttpUtil;
import com.epicsaas.app.ksdapp.util.TestUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.codec.digest.Crypt;
import org.apache.commons.codec.digest.Md5Crypt;
import org.apache.commons.codec.digest.UnixCrypt;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;

import javax.validation.Valid;

import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Member控制器。
 * 
 */
@Controller
@RequestMapping(value = "/phone/member")
public class MemberController {

    private static Logger LOG = LoggerFactory.getLogger(MemberController.class);

    @Resource
    private IUserService userService;

    /** 3.2.1	注册（写法1） */
    @RequestMapping(value = "/register", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object register(String captchaId, String captcha, String username, String password, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.2.2	检查用户名是否可用（写法2）  */
    @RequestMapping(value = "/check_username", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object check_username(String username, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.2.3	检查邮箱是否被使用 */
    @RequestMapping(value = "/check_email", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object check_email(String email, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.2.4	检查手机号是否被使用 */
    @RequestMapping(value = "/checkMobile", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object checkMobile(String mobile, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.3	验证密码是否正确（需要登录） */
    @RequestMapping(value = "/check_password", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object check_password(String password, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.4	修改密码（需要登录） */
    @RequestMapping(value = "/update_password", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object update_password(String password, String newPassword, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.5.1	找回密码 */
    @RequestMapping(value = "/find_password", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object find_password(String username, String captchaId, String captcha, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.5.2	重置密码 */
    @RequestMapping(value = "/reset_password", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object reset_password(String username, String code, String password, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.5.3找回密码(无图形验证码) */
    @RequestMapping(value = "/findWithNoCaptcha_password", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object findWithNoCaptcha_password(String username, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.6	登录 */
    @RequestMapping(value = "/login", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object login(@RequestParam("username") String username, @RequestParam("password") String password,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        UserBaseInfo userBeanInfo = new UserBaseInfo();

        //http://www.kongshidian.com/cpp/index.php?r=account/site/hello&password=123456&flag=1
        //http://www.kongshidian.com/cpp/index.php?r=account/site/hello&password=123456&flag=0&password2=$2a$10$Af3CHrH/jQ6n9b0MZSAFLuX01wmyLF/HWnbCOKG4JqGUbVd3SwY9K
        //        byte[] ret =  HttpUtil.doGet("http://www.kongshidian.com/cpp/index.php?r=account/site/hello&flag=1&password="+password);
        //        System.out.println(new String(ret));
        //        ret = HttpUtil.doGet("http://www.kongshidian.com/cpp/index.php?r=account/site/hello&password="+password+"&flag=0&password2="+new String(ret));
        //        System.out.println(new String(ret));

        UserCriteria userCriteria = new UserCriteria();
        userCriteria.createCriteria().andUsernameEqualTo(username);
        ServiceResult<List<UserAO>> userListRet = userService.selectByCriteria(userCriteria);
        if (userListRet.isSucceed() && !CollectionUtils.isEmpty(userListRet.getData())) {
            UserAO u = userListRet.getData().get(0);

            byte[] ret = HttpUtil.doGet("http://www.kongshidian.com/cpp/index.php?r=account/site/hello&password="
                    + password + "&flag=0&password2=" + u.getPassword());
            System.out.println(new String(ret));
            if (null == ret || new String(ret).equals("0")) { //登陆失败
                return userBeanInfo;
            }

            userBeanInfo.setId(u.getId());
            userBeanInfo.setToken(u.getId() + System.currentTimeMillis());
            userBeanInfo.setUserpass(u.getPassword());
            userBeanInfo.setId(u.getId());
            userBeanInfo.setUsername(u.getUsername());
        }
        return userBeanInfo;
    }

    /** 3.7检查用户是否登录      */
    @RequestMapping(value = "/login/check", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object check(HttpServletRequest request) {
        ServiceResult<Object> ret = new ServiceResult<Object>();
        return ret;
    }

    /** 3.8 注销 退出登录    */
    @RequestMapping(value = "/logout", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object logout(HttpServletRequest request) {
        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    //账户管理
    /** 3.9.2分页获取收货地址 (需要登录)*/
    @RequestMapping(value = "/consigneeAddress", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object consigneeAddress(String userid, int pageNumber, int pageSize, String orderProperty,
            String orderDirection, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        PageEntity<MyConsigneeAddress> ret = new PageEntity<MyConsigneeAddress>();
        List<MyConsigneeAddress> myConsigneeAddressList = new ArrayList<MyConsigneeAddress>();

        ServiceResult<UserAO> retUserAO = userService.getById(userid);
        if (retUserAO.isSucceed() && null != retUserAO.getData()) {
            UserAO userAO = retUserAO.getData();
            if (StringUtils.isBlank(userAO.getAddress())) {
                return ret;
            } else {
                MyConsigneeAddress myConsigneeAddress = new MyConsigneeAddress();
                myConsigneeAddress.setAddress(userAO.getAddress());
                myConsigneeAddress.setConsignee(userAO.getProfile());
                myConsigneeAddress.setIsDefault(true);
                myConsigneeAddress.setZipCode("");
                myConsigneeAddress.setPhone(userAO.getUsername());
                myConsigneeAddress.setAreaName("");
                myConsigneeAddress.setId(1);
                myConsigneeAddressList.add(myConsigneeAddress);
            }
        }
        ret.setContent(myConsigneeAddressList);
        return ret;
    }

    /** 3.9.3新建收货地址  (需要登录)*/
    @RequestMapping(value = "/newAddress", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object newAddress(String address, String consignee, Boolean isDefault, String phone, String zipCode,
            String area, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.9.4修改收货地址  */
    @RequestMapping(value = "/modifyAddress/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object modifyAddress(@PathVariable long id, String address, String consignee, Boolean isDefault,
            String phone, String zipCode, String area, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.9.4修改收货地址  */
    @RequestMapping(value = "/deleteAddress/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object deleteAddress(@PathVariable long id, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.10.1 关注某个商品 */
    @RequestMapping(value = "/favorite/add/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object favorite_add(@PathVariable long id, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.10.2 查看我的关注列表 */
    @RequestMapping(value = "/favorite/list", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object listFavorite(int pageNumber, int pageSize, String orderProperty, String orderDirection, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /** 3.10.3 取消某个商品的关注 */
    @RequestMapping(value = "/favorite/delete/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object deleteFavorite(@PathVariable String id, int pageNumber, int pageSize, String orderProperty,
            String orderDirection, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        ServiceResult<Object> ret = new ServiceResult<Object>();

        return ret;
    }

    /**
     * 保存头像
     */
    @RequestMapping(value = "/image", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object image(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        return null;
    }

    /**10.1  获取头像image( 需登录) */

    @RequestMapping(value = "/get_image", method = { RequestMethod.GET, RequestMethod.POST })
    public String get_image(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        return "";
    }

    /** 账户基本信息 */
    @RequestMapping(value = "/info", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object info(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        UserInfo userInfo = new UserInfo();
        userInfo.setBalance(10);
        userInfo.setName("18287113237");
        userInfo.setUsername("郭华刚");

        return userInfo;
    }

    /**  15.2查询配送方式 */
    @RequestMapping(value = "/order/deliveryPrice", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order_deliveryPrice(long areaId, int weight, String payPrice, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        List<Logistics> LogisticsList = new ArrayList<Logistics>();

        return LogisticsList;
    }

    /**15.3 立即购买      **/
    @RequestMapping(value = "/order/buyNow", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object buyNow(long itemId, int quantity, long receiverId, String paymentMethodId, String deliveryCorpId,
            String code, boolean isInvoice, String invoiceTitle, boolean useBalance, String promotionType, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        OrderList orderList = new OrderList();

        return orderList;
    }

    /**16.2  获取订单列表 */
    @RequestMapping(value = "/order/create", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order_create(String cartToken, long receiverId, String paymentMethodId, String deliveryCorpId,
            String code, boolean isInvoice, String invoiceTitle, boolean useBalance, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        OrderList orderList = new OrderList();

        return orderList;
    }

    /**  进入到订单流程 */
    @RequestMapping(value = "/order/payment", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order_payment(String sn, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        OrderDTO ret = new OrderDTO();

        return ret;
    }

    /** 15.6购买使用优惠券 */
    @RequestMapping(value = "/order/getCouponCodes", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order_getCouponCodes(boolean isCart, String productId, String quantity, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        List<CouponCode> list = new ArrayList<CouponCode>();

        return list;
    }

    /**16.2  获取订单列表 */
    @RequestMapping(value = "/order/myOrder", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order_myOrder(String orderStatus, int pageNumber, int pageSize, String orderProperty,
            String orderDirection, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<OrderList> bean = new PageEntity<OrderList>();

        return bean;
    }

    /**16.3  获取订单详情 */
    @RequestMapping(value = "/order/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order(@PathVariable String id, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<OrderList> bean = new PageEntity<OrderList>();

        return bean;
    }

    /** 16.3.1  订单签收 */
    @RequestMapping(value = "/order/signIn/{sn}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object order_signIn(@PathVariable String sn, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        OrderList bean = new OrderList();
        return bean;
    }

    /** 16.4  我的优惠券 */
    @RequestMapping(value = "/coupon/list", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object coupon_list(String status, int pageNumber, int pageSize, String orderProperty, String orderDirection,
            Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<CouponCode> bean = new PageEntity<CouponCode>();
        return bean;
    }

    /** 16.5评价   */
    @RequestMapping(value = "/reviews/review", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object reviews_review(String status, int pageNumber, int pageSize, String orderProperty,
            String orderDirection, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<CouponCode> bean = new PageEntity<CouponCode>();
        return bean;
    }

    /** 16.10可晒单/评价列表 */
    @RequestMapping(value = "/reviews/list", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object reviews_list(String status, int pageNumber, int pageSize, String orderProperty,
            String orderDirection, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<Reviews> bean = new PageEntity<Reviews>();
        return bean;
    }

    //我的消息
    /** 16.7我的消息 */
    @RequestMapping(value = "/message/list", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object message_getNumber(int pageNumber, int pageSize, String orderProperty, String orderDirection,
            Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<MyMessage> pageEntity = new PageEntity<MyMessage>();

        List<MyMessage> content = new ArrayList<MyMessage>();

        MyMessage message = new MyMessage();
        message.setContent("xxxxxxxxx");
        message.setId(1);
        message.setTitle("title");
        message.setCreateDate(System.currentTimeMillis());
        message.setQuantity(22);
        message.setIsRead(Type.no);
        content.add(message);

        pageEntity.setContent(content);
        pageEntity.setTotal(22);
        pageEntity.setTotalPages(22);
        pageEntity.setPageSize(1);
        pageEntity.setPageNumber(1);

        return pageEntity;
    }

    /**  未读消息个数 */
    @RequestMapping(value = "/message/getNumber", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object message_getNumber(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        MyMessage message = new MyMessage();
        message.setContent("xxxxxxxxx");
        message.setId(1);
        message.setTitle("title");
        message.setCreateDate(System.currentTimeMillis());
        message.setQuantity(22);
        message.setIsRead(Type.no);

        return message;
    }

    /** 16.8点击消息  */
    @RequestMapping(value = "/message/hit/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object message_hit(@PathVariable long id, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<MyMessage> pageEntity = new PageEntity<MyMessage>();

        List<MyMessage> content = new ArrayList<MyMessage>();

        MyMessage message = new MyMessage();
        message.setContent("xxxxxxxxx");
        message.setId(1);
        message.setTitle("title");
        message.setCreateDate(System.currentTimeMillis());
        message.setQuantity(22);
        message.setIsRead(Type.no);
        content.add(message);

        pageEntity.setContent(content);
        pageEntity.setTotal(22);
        pageEntity.setTotalPages(22);
        pageEntity.setPageSize(1);
        pageEntity.setPageNumber(1);

        return pageEntity;
    }

    /** 16.9 删除消息 */
    @RequestMapping(value = "/message/delete/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object message_delete(@PathVariable long id, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<MyMessage> pageEntity = new PageEntity<MyMessage>();

        List<MyMessage> content = new ArrayList<MyMessage>();

        MyMessage message = new MyMessage();
        message.setContent("xxxxxxxxx");
        message.setId(1);
        message.setTitle("title");
        message.setCreateDate(System.currentTimeMillis());
        message.setQuantity(22);
        message.setIsRead(Type.no);
        content.add(message);

        pageEntity.setContent(content);
        pageEntity.setTotal(22);
        pageEntity.setTotalPages(22);
        pageEntity.setPageSize(1);
        pageEntity.setPageNumber(1);

        return pageEntity;
    }

    /** 16.11我的浏览记录 */
    @RequestMapping(value = "/browse/list", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object browse_list(int pageNumber, int pageSize, String orderProperty, String orderDirection, Model model,
            HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<Product> bean = new PageEntity<Product>();
        return bean;
    }

    @RequestMapping(value = "/browse/delete/{id}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object browse_delete(@PathVariable long id, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<Product> bean = new PageEntity<Product>();
        return bean;
    }

    @RequestMapping(value = "/browse/deleteAll", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object browse_deleteAll(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());

        PageEntity<Product> bean = new PageEntity<Product>();
        return bean;
    }

}
